package com.phkj.qdh.ui.adapter

import android.content.Context
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import com.phkj.qdh.R
import com.phkj.qdh.bean.InstructionBean

class InstructionSheetAdapter : BaseQuickAdapter<InstructionBean, QuickViewHolder>() {
    override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: InstructionBean?) {
        val iv = holder.getView<ImageView>(R.id.iv_state)
        val tvState = holder.getView<TextView>(R.id.tv_state)
        if (item?.deal == 1) {
            iv.setImageResource(R.mipmap.img_yichuli)
        } else {
            iv.setImageResource(R.mipmap.img_daichuli)
        }
        holder.setText(R.id.tv_title, "指令单")
        holder.setText(R.id.tv_content, "${item?.policeSituationContent}")
        holder.setText(R.id.tv_time, item?.createdTime)
        when (item?.applyStatus) {
            1 -> {
                tvState.text = "待处理"
            }
            2 -> {
                tvState.text = "已处理待确定"
            }
            else -> {
                tvState.text = "已完成"
            }
        }

    }

    override fun onCreateViewHolder(
        context: Context, parent: ViewGroup, viewType: Int
    ): QuickViewHolder {
        return QuickViewHolder(R.layout.item_instruction_sheet, parent)
    }
}